<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /**
     * 封装一个函数，函数参数为传入的字符串
     * 返回值为对象结构
    */
    var searchStr = "?id=18&page=12";
    var ad = function(searchStr){
            searchStr = searchStr.slice(1);
            var arr = searchStr.split("&");
            var obj = {};
            console.log(arr);
            for(var i = 0; i < arr.length; i++){
                var childArr = arr[i].split("=");
                obj[childArr[0]] = childArr[1];
            }
            return obj;
        }
</script>
</html>